home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / os2 / cenv2_19.arj / PMDLL.LIB < prev    next >
Text File  |  1994-03-08  |  7KB  |  134 lines

  1. /*****************************************************************************
  2.  *** PMdll.lib - This library contains wrappers functions and definitions  ***
  3.  *** ver.1       used in making calls into the Presentation Manager        ***
  4.  ***             DLLs.  This file may be #include'ed into your source      ***
  5.  ***             file, or you may want to improve speed and memory use by  ***
  6.  ***             copying just the relevant sections into your source code. ***             ***
  7.  *****************************************************************************/
  8.  
  9. WinCreateObject(ClassName,Title,SetupString,Location,Flags)
  10. {
  11.    // WinCreateObject: Create an instance of an object class
  12.    //  ClassName: A string which contains the name of the class of which this object is a member.
  13.    //  Title: A string which contains the initial title of the object as it is to appear
  14.    //         when displayed on the user interface underneath an icon or on
  15.    //         the title bar of an open object.
  16.    //  SetupString: A series of "keyname=value" pairs separated by commas, that change the behavior of the object.
  17.    //               Each object class documents its keynames and the parameters parameters it expects to see immediately following.
  18.    //               Note that ALL parameters have safe defaults, so it is never necessary to pass
  19.    //               unnecessary parameters to an object.
  20.    //  Location: Folder location.  This can be the real folder path name or one of these:
  21.    //            <WP_NOWHERE>, <WP_DESKTOP>, <WP_OS2SYS>, <WP_TEMPS>, <WP_CONFIG>, <WP_START>, <WP_INFO>, <WP_DRIVES>
  22.    //  Flags: Creation flags:
  23.          #define CO_FAILIFEXISTS     0
  24.          #define CO_REPLACEIFEXISTS  1
  25.          #define CO_UPDATEIFEXISTS   2
  26.    //  Return: returns handle for object, which is NULL (0) for error, else
  27.    //          handle can be used for further calls for this object
  28.    #define ORD_WINCREATEOBJECT   281
  29.    return PMDynamicLink("PMWP",ORD_WINCREATEOBJECT,BIT32,CDECL,
  30.                         ClassName,Title,SetupString,Location,Flags)
  31. }
  32.  
  33. WinQueryObject(ObjectID)
  34. {
  35.    // WinQueryObject: Return a handle to the persistent ObjectID
  36.    //  ObjectID: The ObjectID of an existing object, for example "<WP_DESKTOP>", or
  37.    //            alternatively the fully qualified filename of any file or directory. 
  38.    //  Return: NULL for error, else return a handle to the object created.
  39.    //          This handle is persistent and can be used for the WinSetObjectData
  40.    //          and WinDestroyObject function calls. 
  41.    #define ORD_WINQUERYOBJECT    252
  42.    return PMDynamicLink("PMWP",ORD_WINQUERYOBJECT,BIT32,CDECL,ObjectID);
  43. }
  44.  
  45. WinSetObjectData(WPObjectHandle,SetupString)
  46.    // set parameters in SetupString for WPObjectHandle, which is like the value
  47.    // returned by WinCreateObject.
  48.    // Return TRUE for success and FALSE for error.
  49. {
  50.    #define ORD_WINSETOBJECTDATA  250
  51.    return PMDynamicLink("PMWP",ORD_WINSETOBJECTDATA,BIT32,CDECL,WPObjectHandle,SetupString)
  52. }
  53.  
  54. WinSwitchToProgram(SwitchHandle)
  55. {
  56.    // Switch to this handle, where SwitchHandle is an entry entry handle in the window list.
  57.    // Returns 0 for success or one of the following errors:
  58.       #define INV_SWITCH_LIST_ENTRY_HANDLE     4610  // Invalid Window List entry handle of the program to be activated.
  59.       // #define NOT_PERMITTED_TO_CAUSE_SWITCH ????  // Requesting program is not the current foreground process.
  60.    #define ORD_WIN32SWITCHTOPROGRAM    131
  61.    return PMDynamicLink("PMSHAPI",ORD_WIN32SWITCHTOPROGRAM,BIT32,CDECL,SwitchHandle);
  62.  
  63. }
  64.  
  65. WinQuerySwitchHandle(WindowHandle,ProcessID)
  66. {
  67.    #define ORD_WIN32QUERYSWITCHHANDLE  125
  68.    return PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHHANDLE,BIT32,CDECL,
  69.                         WindowHandle,ProcessID);
  70. }
  71.  
  72. WinQuerySwitchList(AnchorBlock)
  73.    // return an array of switch list handles.  Number can be determined by
  74.    // the size of the array returned, which will be NULL for an error.
  75. {
  76.    #define FIRST_SWENTRY_OFFSET 4 // offset in returned block of first entry
  77.    #define SWENTRY_SIZE 100       // size of each entry in entry array
  78.    #define ORD_WIN32QUERYSWITCHLIST 126
  79.    // determine how big the blob must be to hold the data received and then
  80.    // allocate it much bigger just to be sure
  81.    _WQCount = PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHLIST,BIT32,CDECL,AnchorBlock,NULL,0);
  82.    if ( _WQCount == 0 )
  83.       return NULL;
  84.    // create big big big extrabig BLOb to hold received data
  85.    _WinSizeNeeded = (_WQCount * SWENTRY_SIZE) + FIRST_SWENTRY_OFFSET;
  86.    BLObSize(_WQblob,_WinSizeNeeded*2);
  87.    // once again, query for list of WinSwitches
  88.    _WQCount = PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHLIST,BIT32,CDECL,
  89.                             AnchorBlock,_WQblob,_WinSizeNeeded * 3 / 2);
  90.    if ( _WQCount == 0 )
  91.       return NULL;
  92.    // create array for _WQCount entries to hold the Switch entries
  93.  
  94.    for ( i = 0, _WEoffset = FIRST_SWENTRY_OFFSET; i < _WQCount; i++, _WEOffset += SWENTRY_SIZE )
  95.       _SWEntry[i] = BLObGet(_WQblob,_WEoffset,UWORD32);
  96.    // finished, and so return this array
  97.    return _SWEntry;
  98. }
  99.  
  100. WinQuerySwitchEntry(SwitchListHandle,SwitchControlData)
  101.    // Query based on this SwitchListHandle for SwitchControl Data.  Return 0 for
  102.    // success else error.  Set SwitchControlData to structure with the following
  103.    // structure members (all integers except for title):
  104.    //  hwnd:      Window Handle
  105.    //  hwndIcon:  Icon handle
  106.    //  program:  Program handle
  107.    //  process:   Process ID
  108.    //  session:   Session ID
  109.    //  visibility:  ???
  110.    //  jump:        ???
  111.    //  title:     title of this window; string
  112.    //  ProgType:  program type
  113.  {
  114.    // create blob to hold all the data
  115.    BLObSize(_SwEntry,SWENTRY_SIZE);
  116.    #define ORD_WIN32QUERYSWITCHENTRY         124
  117.    _result = PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHENTRY,BIT32,CDECL,SwitchListHandle,_SwEntry);
  118.    if ( _result == 0 ) {
  119.       // place each field in SwitchControlData structure
  120.       undefine(SwitchControlData);
  121.       SwitchControlData.hwnd = BLObGet(_SwEntry,_offset=0,UWORD32);
  122.       SwitchControlData.hwndIcon = BLObGet(_SwEntry,_offset+=4,UWORD32);
  123.       SwitchControlData.program = BLObGet(_SwEntry,_offset+=4,UWORD32);
  124.       SwitchControlData.process = BLObGet(_SwEntry,_offset+=4,UWORD32);
  125.       SwitchControlData.session = BLObGet(_SwEntry,_offset+=4,UWORD32);
  126.       SwitchControlData.visibility = BLObGet(_SwEntry,_offset+=4,UWORD32);
  127.       SwitchControlData.jump = BLObGet(_SwEntry,_offset+=4,UWORD32);
  128.       strcpy(SwitchControlData.title,BLObGet(_SwEntry,_offset+=4,68));
  129.       SwitchControlData.ProgType = BLObGet(_SwEntry,_offset+=68,UWORD32);
  130.    }
  131.    return _result;
  132. }
  133.  
  134.